﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace LitTools
{
    /// <summary>
    /// UI信息类
    /// </summary>
    public class UIInfo
    {
        public UIBase uibase;
        public Canvas canvas;
        public GameObject go;

        private float hideTime;

        public UIInfo(UIBase uibase, Canvas canvas, GameObject go)
        {
            this.uibase = uibase;
            this.canvas = canvas;
            this.go = go;
        }

        public void Show()
        {
            uibase.OnShow();
            hideTime = 0;
            canvas.enabled = true;
        }

        public void Hide()
        {
            uibase.OnHide();
            canvas.enabled = false;
            hideTime = 0;
        }

        public void Destroy()
        {
            uibase.OnDestroy();
            GameObject.Destroy(canvas.gameObject);
        }

        public bool Refresh()
        {
            hideTime += Time.deltaTime;
            if (hideTime >= uibase.RemainTime)
            {
                Destroy();
                return true;
            }
            return false;
        }
    }
}
